<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/layouts/template.xhtml">
	<ui:define name="body">
		<h:form id="form" acceptcharset="ISO-8859-1">
			<p:panel header="#{msgs['massai.serviceItem.header.consult']}">

				<h:panelGrid style="width: 100%;">
					<p:commandButton value="#{msgs['common.register']}" action="serviceItemRegister" 
						ajax="false" immediate="true" styleClass="buttonNew" tabindex="1"
						rendered="#{sessionBean.showAction('supportServiceItem', 'insert')}" />
				</h:panelGrid>

				<fieldset>
					<legend><h:outputText value="#{msgs['common.search.filter']}" /></legend>
					<h:panelGrid>
						<h:panelGrid>
							<p:outputLabel for="category" value="#{msgs['massai.serviceItem.categoryLevel']}" />
							<p:selectOneMenu 
								id="category" tabindex="1" value="#{serviceItemBean.serviceItem.categoryLevel}"
								style="width: 250px;" label="#{msgs['massai.serviceItem.categoryLevel']}"
								converter="entityConverter">
								<f:selectItems value="#{serviceItemBean.listCategoryLevel()}" />
							</p:selectOneMenu>
						</h:panelGrid>

						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.serviceItem.description']}" for="description" />
							<p:inputText id="description" tabindex="2" value="#{serviceItemBean.serviceItem.description}" 
								style="width: 250px;" maxlength="100" />
						</h:panelGrid>
					</h:panelGrid>

					<h:panelGrid style="width: 100%">
						<p:commandButton tabindex="3" value="#{msgs['common.search']}" 
							ajax="true" actionListener="#{serviceItemBean.find()}" update="form"
							rendered="#{sessionBean.showAction('supportServiceItem', 'search')}" />
					</h:panelGrid>
				</fieldset>

				<p:spacer height="20px" />

				<p:dataTable var="serv" value="#{serviceItemBean.dataModel}" rows="10" paginator="true" paginatorPosition="bottom"
					paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
					currentPageReportTemplate="{currentPage} de {totalPages}" rowsPerPageTemplate="5,10,20"
					id="dataTable" lazy="true" rowIndexVar="rowIndex" emptyMessage="#{msgs['common.no.record.found']}">
					<f:facet name="header"><p:outputLabel value="#{msgs['massai.serviceItem.list']}" /></f:facet>

					<p:column headerText="#{msgs['massai.serviceItem.level']}" sortBy="#{serv.categoryLevel}" width="100">
                        <h:outputText value="#{serv.categoryLevel.code}.#{serviceItemBean.completedZerosLeft(serv.levelService, 3)}" />
                    </p:column>

                    <p:column headerText="#{msgs['massai.serviceItem.unitMeasure']}" sortBy="#{serv.unitMeasure}" width="150">
                        <h:outputText value="#{serv.unitMeasure.acronym} - #{serv.unitMeasure.nameMeasure}" />
                    </p:column>
                    
                    <p:column headerText="#{msgs['massai.serviceItem.description']}" sortBy="#{serv.description}">
                        <h:outputText value="#{serv.description}" />
                    </p:column>

                    <p:column headerText="#{msgs['common.delete']}" width="60" style="text-align: center;" 
                    	rendered="#{sessionBean.showAction('supportServiceItem', 'delete')}">
						<h:commandLink id="delete"
							onclick="if (!window.confirm('Deseja excluir esse registro?') ) {return false}" 
			            	actionListener="#{serviceItemBean.delete(serv)}">
							<img src="#{facesContext.externalContext.requestContextPath}/images/ico_remove.png" 
								width="16" height="16" border="0" name="#{msgs['common.delete']}" 
								alt="#{msgs['common.delete']}" id="icoRemove"
								title="#{msgs['common.delete']}" />
						</h:commandLink>
					</p:column>

					<p:column headerText="#{msgs['common.update']}" width="32" style="text-align: center;" 
						rendered="#{sessionBean.showAction('supportServiceItem', 'update')}">
						<h:link outcome="serviceItemRegister">
							<img src="#{facesContext.externalContext.requestContextPath}/images/ico_edit.png" 
								width="16" height="16" border="0" name="#{msgs['common.update']}" 
								title="#{msgs['common.update']}" alt="#{msgs['common.update']}" id="icoEdit" />
							<f:param name="param" value="#{serv.id}" />
						</h:link>
					</p:column>
                </p:dataTable>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
</html>